package com.wbsxch.shiro.service.impl;

import com.github.pagehelper.PageHelper;
import com.wbsxch.shiro.domain.Role;
import com.wbsxch.shiro.dto.RoleDTO;
import com.wbsxch.shiro.mapper.RoleMapper;
import com.wbsxch.shiro.service.RoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public int insert(RoleDTO record) {
        return roleMapper.insert(record);
    }

    @Override
    public int delete(Long id) {
        return roleMapper.delete(id);
    }

    @Override
    public int update(RoleDTO record) {
        return roleMapper.update(record);
    }

    @Override
    public List<RoleDTO> selectAll(RoleDTO record) {
        return roleMapper.selectAll(record);
    }

    @Override
    public List<RoleDTO> selectAll(RoleDTO record, Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        return roleMapper.selectAll(record);
    }

    @Override
    public List<RoleDTO> selectAll(RoleDTO record, Integer currentPage, Integer pageSize, String orderBy) {
        PageHelper.startPage(currentPage,pageSize,orderBy);
        return roleMapper.selectAll(record);
    }

    @Override
    public RoleDTO selectOne(Long id) {
        return roleMapper.selectOne(id);
    }
}
